<template>
	<view class="u-demo">
		<u-toast ref="uToast"></u-toast>
		<u-grid :col="col" v-if="!isSwiper" :border="border">
			<u-grid-item name="item1" :index="0" @click="toClaim">
				<u-icon name="plus-square-fill" :size="46"></u-icon>
				<view class="grid-text">员工认领</view>
			</u-grid-item>
			<u-grid-item name="item1" :index="0" @click="myStaff">
				<u-icon name="account-fill" :size="46"></u-icon>
				<view class="grid-text">我的员工</view>
			</u-grid-item>
			<u-grid-item :index="1" @click="todayEntryDep">
				<u-icon name="plus-people-fill" :size="46"></u-icon>
				<view class="grid-text">今日入职</view>
			</u-grid-item>
			<u-grid-item :index="1" @click="todayDep">
				<u-icon name="minus-people-fill" :size="46"></u-icon>
				<view class="grid-text">今日离职</view>
			</u-grid-item>
			<!-- <u-grid-item :index="2" @click="monthTimeRange">
				<u-icon name="hourglass" :size="46"></u-icon>
				<view class="grid-text">本月员工工时</view>
			</u-grid-item> -->
		</u-grid>
	</view>
</template>

<script>
	export default {
		created() {
			const token = uni.getStorageSync('token');
			console.log(token)
			if (!token || token === '') {
				uni.redirectTo({
					url: '/pages/login/login'
				})
			}
		},
		data() {
			return {
				list: ['integral', 'kefu-ermai', 'coupon', 'gift', 'scan', 'pause-circle', 'wifi', 'email', 'list'],
				isSwiper: false,
				current: 0,
				border: true,
				col: 3
			};
		},
		methods: {
			isSwiperChange(index) {
				this.isSwiper = index == 0 ? true : false;
			},
			borderChange(index) {
				this.border = index == 0 ? true : false;
			},
			colChange(index) {
				this.col = index == 0 ? 3 : 4;
			},
			click(index) {
				this.$refs.uToast.show({
					title: `点击了第${index + 1}宫格`,
					type: 'warning'
				})
			},
			change(e) {
				this.current = e.detail.current;
			},
			toClaim() {
				uni.navigateTo({
					url: '/pages/Claim/Claim'
				})
			},
			myStaff() {
				uni.navigateTo({
					url: '/pages/selectFactory/selectFactory?nextUri=/pages/mystaff/mystaff'
				})
			},
			todayEntryDep() {
				uni.navigateTo({
					url: '/pages/selectFactory/selectFactory?nextUri=/pages/todayEntryDep/todayEntryDep'
				})
			},
			todayDep() {
				uni.navigateTo({
					url: '/pages/selectFactory/selectFactory?nextUri=/pages/todayDep/todayDep'
				})
			},
			// monthTimeRange() {
			// 	uni.navigateTo({
			// 		url: '/pages/monthTimeRange/monthTimeRange'
			// 	})
			// },
			// 针对单个grid-item的事件
			itemClick(index) {
				// console.log(index);
			}
		}
	};
</script>

<style scoped lang="scss">
.grid-text {
	font-size: 28rpx;
	margin-top: 4rpx;
	color: $u-type-info;
}

.badge-icon {
	position: absolute;
	width: 40rpx;
	height: 40rpx;
}

.swiper {
	height: 480rpx;
}

.indicator-dots {
	margin-top: 40rpx;
	display: flex;
	justify-content: center;
	align-items: center;
}

.indicator-dots-item {
	background-color: $u-tips-color;
	height: 6px;
	width: 6px;
	border-radius: 10px;
	margin: 0 3px;
}

.indicator-dots-active {
	background-color: $u-type-primary;
}
</style>
